package com.one.consumer.reserve.presenter;

import android.content.Context;

import com.one.common.model.http.callback.ObserverOnResultListener;
import com.one.common.presenter.BaseApiPresenter;
import com.one.common.view.base.BaseActivity;
import com.one.common.view.base.IListView;
import com.one.consumer.reserve.model.ReserveModel;
import com.one.common.common.order.extra.ReserveExtra;
import com.one.consumer.reserve.model.item.CustomItem;
import com.one.consumer.reserve.model.item.ReserveItem;

import java.util.ArrayList;

/**
 * Author: zhulunjun
 * Time  : 2018/10/25 11:12
 * email : zhulunjun@qq.com
 * Describe : 预约中心
 **/
public class ReserveCenterPresenter extends BaseApiPresenter<IListView, ReserveModel> {

    public ReserveCenterPresenter(IListView mView, Context mContext) {
        super(mView, mContext, new ReserveModel((BaseActivity) mContext));
    }


    /**
     * 获取预约列表
     */
    public void getReserveList(String type) {
        if(type.equals(ReserveExtra.STYLE_CU)){
            getCustomList();
            return;
        }
        mModel.getReserveList(mView.getPage() + "", type, new ObserverOnResultListener<ArrayList<ReserveItem>>() {
            @Override
            public void onResult(ArrayList<ReserveItem> reserveItems) {
                if (mView != null) {
                    mView.loadSuccess(reserveItems);

                }
            }
        });
    }

    /**
     * 获取定制加配列表
     */
    private void getCustomList(){
        mModel.getCustomList(mView.getPage() + "", new ObserverOnResultListener<ArrayList<CustomItem>>() {
            @Override
            public void onResult(ArrayList<CustomItem> customItems) {
                if (mView != null) {
                    mView.loadSuccess(customItems);

                }
            }
        });
    }
}
